package server;


import java.util.HashMap;
import java.util.Map;


/**
 * Server 服务列表 包含的必须属性： http://blog.jobbole.com/92290/
 */
public class RPCServer {

    /**
     * 服务器端口号
     */
    private int port;

    /**
     * 是否运行
     */
    private boolean isRun;

    private Map<String, Object> serviceEngine = new HashMap<String, Object>();

    public int getPort() {
        return port;
    }

    public void setPort(int port) {
        this.port = port;
    }

    public boolean isRun() {
        return isRun;
    }

    public RPCServer(int port) {
        super();
        this.port = port;
    }

    public Map<String, Object> getServiceEngine() {
        return serviceEngine;
    }

    /**
     * Description:注册服务
     * 
     * @param name
     * @param impl
     *            void
     * @see
     */
    public void register(String name, Object impl) {
        serviceEngine.put(name, impl);
    }

    /**
     * Description:启动服务 void
     *
     * @see
     */
    public void start() {
        isRun = true;
        new Listener(this).start();
    }

    /**
     * Description:停止服务 void
     *
     * @see
     */
    public void stop() {
        isRun = false;
    }

}
